<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>个人中心</title>
<meta name="keywords"  content="KEYWORDS..." />
<meta name="description" content="DESCRIPTION..." />
<meta name="author" content="DeathGhost" />
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name='apple-touch-fullscreen' content='yes'>
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="format-detection" content="telephone=no">
<meta name="format-detection" content="address=no">
<link rel="icon" href="/1/images/icon/favicon.ico" type="image/x-icon">
<link rel="apple-touch-icon-precomposed" sizes="57x57" href="/1/images/icon/apple-touch-icon-57x57-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="120x120" href="/1/images/icon/apple-touch-icon-120x120-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="196x196" href="/1/images/icon/apple-touch-icon-196x196-precomposed.png">
<meta name="viewport" content="initial-scale=1, width=device-width, maximum-scale=1, user-scalable=no">
<link rel="stylesheet" type="text/css" href="/1/css/style.css" />
<script src="/1/js/jquery.js"></script>
<script src="/vendor/layer/layer.js"></script>
<script src="/js/ajaxfileupload.js"></script>
</head>
<body>
<!--header-->
<header>
 <h1>个人中心</h1>
 {{--<a href="/home/user/userSet" class="iconfont setIcon">&#42;</a>--}}
</header>
<div style="height:1rem;"></div>
<div class="userInfor">
    <a class="userIcon" onclick="javascript:$('#pic').click();">
        <img id="head_pic" src="{{empty($user->head_pic) ? '/1/images/icon/DefaultAvatar.jpg' : $user->head_pic}}"/>
    </a>
    <input type="file" name="pic" id="pic" style="display:none" onchange="uploadImage('pic')">
 <h2>{{$user->nickname}}</h2>
</div>
<ul class="userList">
 <li><a href="/home/order/index" class="orderListIcon">我的订单</a></li>
 {{--<li><a href="/1/favorite.html" class="collectionIcon">常购清单</a></li>--}}
 <li><a href="/home/user/userSet" class="profileIcon">个人设置</a></li>
</ul>
<!--fixedNav:footer-->
<div style="height:1.2rem;"></div>
@include('home.1.footer')
<script>
    // 上传图片
    function uploadImage(elementId) {
        if (document.getElementById(elementId).files.length === 0) {
            layer.msg('您还未选择图片', {icon: 2});
            return;
        }

        $.ajaxFileUpload({
            fileElementId: elementId,
            url: '{{url('api/upload/image')}}',
            type: 'post',
            dataType: 'json',
            secureuri: false, // 是否启用安全提交，默认为false。
            async : true,
            success: function(res) {
                if (res.status === 1) {
                    $('#head_pic').attr('src', res.info);
                    $.get('{{url('home/user/changeInfo')}}', {field: 'head_pic', val: res.info}); // 修改头像
                } else {
                    layer.msg(res.info, {time: 2000});
                }
            },
            error: function(data, status, e) {
                layer.msg(e, {time: 2000});
            }
        });
    }
</script>
</body>
</html>
